﻿// Original author contact info: Owen Emlen (owene_1998@yahoo.com)
// Note: other individuals may also have contributed to this code
// Project hosted on CodePlex.com as of 1/10/2009 at http://www.codeplex.com/EmlenMud
using System;
using System.Xml.Serialization;
using System.Text;
using System.Threading;
using System.ComponentModel;
using System.Collections;
using System.Collections.Generic;
using BrainTechLLC.ThreadSafeObjects;
using System.Runtime.Serialization;
#if USE_HYPER
using Hyper.ComponentModel;
#endif

namespace BrainTechLLC
{
	public class ViewOfThing : IViewOfThing
	{
		public ThreadSafeLookup<string, List<IViewedProperty>> _viewedProperties = new ThreadSafeLookup<string, List<IViewedProperty>>();

		public ThreadSafeLookup<string, List<IViewedProperty>> ViewedProperties
		{
			get { return _viewedProperties; }
			set { _viewedProperties = value; }
		}

		public override string ToString()
		{
			StringBuilder sb = new StringBuilder();

			if (_viewedProperties != null)
			{
				List<KeyValuePair<string, List<IViewedProperty>>> props = _viewedProperties.AllKeyValuePairs;
				props.Sort((a, b) => a.Key.CompareTo(b.Key));
				foreach (var kvp in props)
				{
					if (kvp.Value != null)
					{
						foreach (var prop in kvp.Value)
						{
							sb.AppendLine(string.Format("{0}: {1}", kvp.Key, prop.ToString()));
						}
					}
				}
			}

			return sb.ToString();
		}
	}
}